home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / sauro.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  11KB  |  367 lines

  1. /***************************************************************************
  2.  
  3. Sauro Memory Map (preliminary)
  4.  
  5. driver by Zsolt Vasvari
  6.  
  7. Main CPU
  8. --------
  9.  
  10. Memory mapped:
  11.  
  12. 0000-dfff    ROM
  13. e000-e7ff    RAM
  14. e800-ebff    Sprite RAM
  15. f000-fbff    Background Video RAM
  16. f400-ffff    Background Color RAM
  17. f800-fbff    Foreground Video RAM
  18. fc00-ffff    Foreground Color RAM
  19.  
  20. Ports:
  21.  
  22. 00        R    DSW #1
  23. 20        R    DSW #2
  24. 40        R    Input Ports Player 1
  25. 60        R   Input Ports Player 2
  26. 80         W  Sound Commnand
  27. c0         W  Flip Screen
  28. c1         W  ???
  29. c2-c4     W  ???
  30. c6-c7     W  ??? (Loads the sound latch?)
  31. c8         W    ???
  32. c9         W    ???
  33. ca-cd     W  ???
  34. ce         W  ???
  35. e0         W    Watchdog
  36.  
  37.  
  38. Sound CPU
  39. ---------
  40.  
  41. Memory mapped:
  42.  
  43. 0000-7fff        ROM
  44. 8000-87ff        RAM
  45. a000         W  ADPCM trigger
  46. c000-c001     W    YM3812
  47. e000        R   Sound latch
  48. e000-e006     W  ???
  49. e00e-e00f     W  ???
  50.  
  51.  
  52. TODO
  53. ----
  54.  
  55. - The readme claims there is a GI-SP0256A-AL ADPCM on the PCB. Needs to be
  56.   emulated.
  57.  
  58. - Verify all clock speeds
  59.  
  60. - I'm only using colors 0-15. The other 3 banks are mostly the same, but,
  61.   for example, the color that's used to paint the gradients of the sky (color 2)
  62.   is different, so there might be a palette select. I don't see anything
  63.   obviously wrong the way it is right now. It matches the screen shots found
  64.   on the Spanish Dump site.
  65.  
  66. - What do the rest of the ports in the range c0-ce do?
  67.  
  68. ***************************************************************************/
  69.  
  70. #include "driver.h"
  71. #include "vidhrdw/generic.h"
  72. #include "cpu/z80/z80.h"
  73.  
  74.  
  75. unsigned char *sauro_videoram2;
  76. unsigned char *sauro_colorram2;
  77.  
  78. void sauro_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  79. void sauro_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  80.  
  81. WRITE_HANDLER( sauro_scroll1_w );
  82. WRITE_HANDLER( sauro_scroll2_w );
  83. WRITE_HANDLER( sauro_flipscreen_w );
  84.  
  85. static WRITE_HANDLER( sauro_sound_command_w )
  86. {
  87.     data |= 0x80;
  88.     soundlatch_w(offset,data);
  89. }
  90.  
  91. static READ_HANDLER( sauro_sound_command_r )
  92. {
  93.     int ret    = soundlatch_r(offset);
  94.     soundlatch_clear_w(offset,0);
  95.     return ret;
  96. }
  97.  
  98. static struct MemoryReadAddress readmem[] =
  99. {
  100.         { 0x0000, 0xdfff, MRA_ROM },
  101.         { 0xe000, 0xebff, MRA_RAM },
  102.         { 0xf000, 0xffff, MRA_RAM },
  103.         { -1 }  /* end of table */
  104. };
  105.  
  106. static struct MemoryWriteAddress writemem[] =
  107. {
  108.         { 0x0000, 0xdfff, MWA_ROM },
  109.         { 0xe000, 0xe7ff, MWA_RAM },
  110.         { 0xe800, 0xebff, MWA_RAM, &spriteram, &spriteram_size },
  111.         { 0xf000, 0xf3ff, videoram_w, &videoram, &videoram_size },
  112.         { 0xf400, 0xf7ff, colorram_w, &colorram },
  113.         { 0xf800, 0xfbff, MWA_RAM, &sauro_videoram2 },
  114.         { 0xfc00, 0xffff, MWA_RAM, &sauro_colorram2 },
  115.         { -1 }  /* end of table */
  116. };
  117.  
  118. static struct IOReadPort readport[] =
  119. {
  120.         { 0x00, 0x00, input_port_2_r },
  121.         { 0x20, 0x20, input_port_3_r },
  122.         { 0x40, 0x40, input_port_0_r },
  123.         { 0x60, 0x60, input_port_1_r },
  124.         { -1 }    /* end of table */
  125. };
  126.  
  127. static struct IOWritePort writeport[] =
  128. {
  129.         { 0xa0, 0xa0, sauro_scroll1_w, },
  130.         { 0xa1, 0xa1, sauro_scroll2_w, },
  131.         { 0x80, 0x80, sauro_sound_command_w, },
  132.         { 0xc0, 0xc0, sauro_flipscreen_w, },
  133.         { 0xc1, 0xce, MWA_NOP, },
  134.         { 0xe0, 0xe0, watchdog_reset_w },
  135.         { -1 }    /* end of table */
  136. };
  137.  
  138. static struct MemoryReadAddress sound_readmem[] =
  139. {
  140.         { 0x0000, 0x7fff, MRA_ROM },
  141.         { 0x8000, 0x87ff, MRA_RAM },
  142.         { 0xe000, 0xe000, sauro_sound_command_r },
  143.         { -1 }  /* end of table */
  144. };
  145.  
  146. static struct MemoryWriteAddress sound_writemem[] =
  147. {
  148.         { 0x8000, 0x87ff, MWA_RAM },
  149.         { 0xc000, 0xc000, YM3812_control_port_0_w },
  150.         { 0xc001, 0xc001, YM3812_write_port_0_w },
  151.       //{ 0xa000, 0xa000, ADPCM_trigger },
  152.         { 0xe000, 0xe006, MWA_NOP },
  153.         { 0xe00e, 0xe00f, MWA_NOP },
  154.         { -1 }  /* end of table */
  155. };
  156.  
  157.  
  158. INPUT_PORTS_START( sauro )
  159.     PORT_START      /* IN0 */
  160.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 )
  161.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 )
  162.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN1 )
  163.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN2 )
  164.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  165.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY  )
  166.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_8WAY  )
  167.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_8WAY  )
  168.  
  169.     PORT_START      /* IN1 */
  170.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_COCKTAIL )
  171.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 | IPF_COCKTAIL)
  172.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 )
  173.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START2 )
  174.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_COCKTAIL | IPF_8WAY )
  175.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_COCKTAIL | IPF_8WAY  )
  176.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_COCKTAIL | IPF_8WAY  )
  177.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_COCKTAIL | IPF_8WAY  )
  178.  
  179.     PORT_START
  180.     PORT_SERVICE( 0x01, IP_ACTIVE_HIGH )
  181.     PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) )
  182.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  183.     PORT_DIPSETTING(    0x02, DEF_STR( On ) )
  184.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Cabinet ) )
  185.     PORT_DIPSETTING(    0x04, DEF_STR( Upright ) )
  186.     PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
  187.     PORT_DIPNAME( 0x08, 0x00, DEF_STR( Free_Play ) )
  188.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  189.     PORT_DIPSETTING(    0x08, DEF_STR( On ) )
  190.     PORT_DIPNAME( 0x30, 0x20, DEF_STR( Difficulty ) )
  191.     PORT_DIPSETTING(    0x30, "Very Easy" )
  192.     PORT_DIPSETTING(    0x20, "Easy" )
  193.     PORT_DIPSETTING(    0x10, "Hard" )                          /* This crashes test mode!!! */
  194.     PORT_DIPSETTING(    0x00, "Very Hard" )
  195.     PORT_DIPNAME( 0x40, 0x40, "Allow Continue" )
  196.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  197.     PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
  198.     PORT_DIPNAME( 0x80, 0x00, "Freeze" )
  199.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  200.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  201.  
  202.     PORT_START
  203.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
  204.     PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
  205.     PORT_DIPSETTING(    0x01, DEF_STR( 3C_1C ) )
  206.     PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
  207.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
  208.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) )
  209.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_2C ) )
  210.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_3C ) )
  211.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
  212.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )
  213.     PORT_DIPNAME( 0x30, 0x20, DEF_STR( Lives ) )
  214.     PORT_DIPSETTING(    0x30, "2" )
  215.     PORT_DIPSETTING(    0x20, "3" )
  216.     PORT_DIPSETTING(    0x10, "4" )
  217.     PORT_DIPSETTING(    0x00, "5" )
  218.     PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
  219.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  220.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  221.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
  222.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  223.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  224. INPUT_PORTS_END
  225.  
  226.  
  227. static struct GfxLayout charlayout =
  228. {
  229.     8,8,    /* 8*8 chars */
  230.     2048,   /* 2048 characters */
  231.     4,      /* 4 bits per pixel */
  232.     { 0,1,2,3 },  /* The 4 planes are packed together */
  233.     { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4},
  234.     { 0*4*8, 1*4*8, 2*4*8, 3*4*8, 4*4*8, 5*4*8, 6*4*8, 7*4*8},
  235.     8*8*4     /* every char takes 32 consecutive bytes */
  236. };
  237.  
  238. static struct GfxLayout spritelayout =
  239. {
  240.     16,16,    /* 16*16 sprites */
  241.     1024,   /* 1024 sprites */
  242.     4,      /* 4 bits per pixel */
  243.     { 0,1,2,3 },  /* The 4 planes are packed together */
  244.     { 1*4, 0*4, 3*4, 2*4, 5*4, 4*4, 7*4, 6*4, 9*4, 8*4, 11*4, 10*4, 13*4, 12*4, 15*4, 14*4},
  245.     { 3*0x8000*8+0*4*16, 2*0x8000*8+0*4*16, 1*0x8000*8+0*4*16, 0*0x8000*8+0*4*16,
  246.       3*0x8000*8+1*4*16, 2*0x8000*8+1*4*16, 1*0x8000*8+1*4*16, 0*0x8000*8+1*4*16,
  247.       3*0x8000*8+2*4*16, 2*0x8000*8+2*4*16, 1*0x8000*8+2*4*16, 0*0x8000*8+2*4*16,
  248.       3*0x8000*8+3*4*16, 2*0x8000*8+3*4*16, 1*0x8000*8+3*4*16, 0*0x8000*8+3*4*16, },
  249.     16*16     /* every sprite takes 32 consecutive bytes */
  250. };
  251.  
  252. static struct GfxDecodeInfo gfxdecodeinfo[] =
  253. {
  254.     { REGION_GFX1, 0, &charlayout  , 0, 64 },
  255.     { REGION_GFX2, 0, &charlayout  , 0, 64 },
  256.     { REGION_GFX3, 0, &spritelayout, 0, 64 },
  257.     { -1 } /* end of array */
  258. };
  259.  
  260.  
  261. static int sauron_interrupt(void)
  262. {
  263.     cpu_cause_interrupt(1,Z80_NMI_INT);
  264.     return -1000;    /* IRQ, why isn't there a constant defined? */
  265. }
  266.  
  267. static struct YM3526interface ym3812_interface =
  268. {
  269.     1,            /* 1 chip (no more supported) */
  270.     3600000,    /* 3.600000 MHz ? */
  271.     { 255 }     /* (not supported) */
  272. };
  273.  
  274.  
  275. static struct MachineDriver machine_driver_sauro =
  276. {
  277.     /* basic machine hardware */
  278.     {
  279.         {
  280.             CPU_Z80,
  281.             4000000,        /* 4 MHz??? */
  282.             readmem,writemem,readport,writeport,
  283.             interrupt,1
  284.         },
  285.         {
  286.             CPU_Z80 | CPU_AUDIO_CPU,
  287.             4000000,        /* 4 MHz??? */
  288.             sound_readmem,sound_writemem,0,0,
  289.             sauron_interrupt,8 /* ?? */
  290.         }
  291.     },
  292.     60, 5000,  /* frames per second, vblank duration (otherwise sprites lag) */
  293.     1,      /* single CPU, no need for interleaving */
  294.     0,
  295.  
  296.     /* video hardware */
  297.     32*8, 32*8, { 1*8, 31*8-1, 2*8, 30*8-1 },
  298.     gfxdecodeinfo,
  299.     1024, 1024,
  300.     sauro_vh_convert_color_prom,
  301.  
  302.     VIDEO_TYPE_RASTER,
  303.     0,
  304.     generic_vh_start,
  305.     generic_vh_stop,
  306.     sauro_vh_screenrefresh,
  307.  
  308.     /* sound hardware */
  309.     0,0,0,0,
  310.     {
  311.         {
  312.             SOUND_YM3812,
  313.             &ym3812_interface
  314.         }
  315.     }
  316. };
  317.  
  318.  
  319. /***************************************************************************
  320.  
  321.   Game driver(s)
  322.  
  323. ***************************************************************************/
  324. ROM_START( sauro )
  325.     ROM_REGION( 0x10000, REGION_CPU1 )          /* 64k for code */
  326.     ROM_LOAD( "sauro-2.bin",     0x00000, 0x8000, 0x19f8de25 )
  327.     ROM_LOAD( "sauro-1.bin",     0x08000, 0x8000, 0x0f8b876f )
  328.  
  329.     ROM_REGION( 0x10000, REGION_CPU2 )          /* 64k for sound CPU */
  330.     ROM_LOAD( "sauro-3.bin",     0x00000, 0x8000, 0x0d501e1b )
  331.  
  332.     ROM_REGION( 0x10000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  333.     ROM_LOAD( "sauro-4.bin",     0x00000, 0x8000, 0x9b617cda )
  334.     ROM_LOAD( "sauro-5.bin",     0x08000, 0x8000, 0xa6e2640d )
  335.  
  336.     ROM_REGION( 0x10000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  337.     ROM_LOAD( "sauro-6.bin",     0x00000, 0x8000, 0x4b77cb0f )
  338.     ROM_LOAD( "sauro-7.bin",     0x08000, 0x8000, 0x187da060 )
  339.  
  340.     ROM_REGION( 0x20000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  341.     ROM_LOAD( "sauro-8.bin",     0x00000, 0x8000, 0xe08b5d5e )
  342.     ROM_LOAD( "sauro-9.bin",     0x08000, 0x8000, 0x7c707195 )
  343.     ROM_LOAD( "sauro-10.bin",    0x10000, 0x8000, 0xc93380d1 )
  344.     ROM_LOAD( "sauro-11.bin",    0x18000, 0x8000, 0xf47982a8 )
  345.  
  346.     ROM_REGION( 0x0c00, REGION_PROMS )
  347.     ROM_LOAD( "82s137-3.bin",    0x0000, 0x0400, 0xd52c4cd0 )  /* Red component */
  348.     ROM_LOAD( "82s137-2.bin",    0x0400, 0x0400, 0xc3e96d5d )  /* Green component */
  349.     ROM_LOAD( "82s137-1.bin",    0x0800, 0x0400, 0xbdfcf00c )  /* Blue component */
  350. ROM_END
  351.  
  352.  
  353.  
  354. static void init_sauro(void)
  355. {
  356.     /* This game doesn't like all memory to be initialized to zero, it won't
  357.        initialize the high scores */
  358.  
  359.     unsigned char *RAM = memory_region(REGION_CPU1);
  360.  
  361.     memset(&RAM[0xe000], 0, 0x100);
  362.     RAM[0xe000] = 1;
  363. }
  364.  
  365.  
  366. GAMEX( 1987, sauro, 0, sauro, sauro, sauro, ROT0, "Tecfri", "Sauro", GAME_IMPERFECT_COLORS )
  367.